package bb.lanxing.mvvm.routebook

import bb.lanxing.device.sgdevcie.xpair.viewmodel.repository.service.RouteBookService
import bb.lanxing.lib.kt.SingletonHolder
import bb.lanxing.model.routebook.RouteBookPreview
import bb.lanxing.net.retrofit.GenericResponse
import bb.lanxing.net.retrofit.XossRetrofitApiClient
import bb.lanxing.model.routebook.RouteBook
import okhttp3.MultipartBody

class RouteBookBuildRepository private constructor() {
    companion object : SingletonHolder<RouteBookBuildRepository>(::RouteBookBuildRepository)

    private val mService by lazy {
        XossRetrofitApiClient.getInstance().create(RouteBookService::class.java)
    }

    suspend fun requestRouteBookPreview(multipartBody: MultipartBody): RouteBookPreview? {
//        val params = RouteBookPreviewParam(list)
        val response = mService.previewRouteBook(multipartBody)
        if (response.isSuccess) {
            return response.data
        }
        return null
    }

    suspend fun createFromGPX(multipartBody: MultipartBody): GenericResponse<RouteBook> {
        return mService.createFromGPX(multipartBody)
    }
}